// import * as React from 'react';
import * as React from 'react';
import { useState } from 'react';
import { Modal, Button } from 'antd';
import { ExclamationCircleOutlined } from '@ant-design/icons';
import { useDispatch, useSelector } from "react-redux"

import { ModelStyle} from './style'

const Model = () => {
  //  函数组件hook
  const dispatch = useDispatch()
  const [visible, setVisible] = useState(false);
  let [isNots, setisNots] = useState(false);
  // const [visible, setVisible] = useState(false);
  // .getIn(["sr"])
  const pushsel = useSelector((state: any) => state.getIn(["sr"]).toJS())
  // console.log(pushsel.pushSelect);
  // console.log(pushsel);

  //  evt:any
  var isNot: any;

  const handleClick = (evt: any) => {
    setVisible(true);
    // console.log(evt.target.parentNode.parentNode.parentNode);
    // console.log(evt.target.parentNode.parentNode.parentNode.className.indexOf('ant-table-row-selected') !== -1 );
    if (evt.target.parentNode.parentNode.parentNode.parentNode.className.indexOf('ant-table-row-selected') !== -1) {
      //  console.log(111);
      setisNots( true )

      isNot = true
    } else {
      isNot = false
      setisNots( false )
    }
    
    // console.log(isNot);

  }
  const handPush = () => {
    console.log(isNots); 
    setVisible(false);
    // window.location.reload()
    if(isNots){
    

      pushsel.pushStore[(pushsel.pushSelect[0])-1].putStorageState ="已入库"
      // console.log(  pushsel.pushStore[(pushsel.pushSelect[0])-1].putStorageState    );
      console.log(  pushsel.pushStore );
      dispatch({
        type: 'fuza',
        data: pushsel.pushStore
    })
      
    }else{
       console.log("未选中");
       
    }

  }









  return (
    <ModelStyle>
      <Button type="primary"   onClick={handleClick}>
        入库完成确认
      </Button>
      {/* <ModelStyle> */}
      <Modal
        title="入库完成确认"
        centered
        visible={visible}
        // isNot?( pushsel.pushStore[(pushsel.pushSelect[0])-1].putStorageState ="已入库"): console.log(( pushsel.pushStore[(pushsel.pushSelect[0])-1].putStorageState)
        // onOk={() => {setVisible(false);  console.log( pushsel.pushStore[(pushsel.pushSelect[0])-1].putStorageState);}}
        onOk={ handPush}
        onCancel={() => setVisible(false)}
        width={500}
        closable={false}

       
        style={{background: "#AFFFF3",textAlign:"center", borderRadius:"25px" }}
        bodyStyle={{background: "#AFFFF3" ,textAlign:"center",}}
        // title= 'Confirm'
        // icon ={<ExclamationCircleOutlined />}
        // content = 'Bla bla ...'
        okText='确认'
        cancelText='取消'
        // footer={{}}
        // footer={[
        //   // 定义右下角 按钮的地方 可根据需要使用 一个或者 2个按钮
        //   <Button key="back">  Submit </Button>,
        //   <Button key="submit" type="primary">
        //       Submit  
        //   </Button>,          ]}


      >
        <h2>入库确认完成？</h2>

      </Modal>
      {/* </ModelStyle> */}
    </ModelStyle>
  );
}

export default Model;
